import java.util.regex.Pattern;
import java.util.regex.Matcher;
/*
 * 	This class represents the algorithm which extracts staff names from the html
 * 	of the university of limericks computing stafflist page.
 */
public class ULStrategy implements Strategy {
 
    public ULStrategy () 
    {}

    public Faculty execute (StringBuffer buff)
    {
    	Faculty ins = new Faculty();
    	Pattern ul = Pattern.compile(">(\\s)?(\\w)+,((\\s)(\\w)*(\\.)?)*",Pattern.CASE_INSENSITIVE);
    	Pattern removeTag = Pattern.compile(">",Pattern.CASE_INSENSITIVE);
    	Matcher rough = ul.matcher(buff);
		Matcher tags =  removeTag.matcher(buff);
		/*
		 * while there are names left,
		 * remove the excess chars,
		 * save as a new person,
		 * add to institute
		 */
		while(rough.find())
		{
			String str = rough.group();
			tags = removeTag.matcher(str);
			str = tags.replaceAll("");
			//System.out.println(str);
			Person p = new Person(str);
			ins.addStaffMember(p);
		}
		    	
        return ins;
    }

}

